package com.sskj.gcc.market;

import android.text.TextUtils;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.rxbus2.RxBus;
import com.sskj.gcc.presenter.BasePresenter;
import com.sskj.level.http.HttpConfig;
import com.sskj.lib.bean.CoinBean;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;

/**
 * @author Xuweijie
 * Create at 2019/8/29
 */
public class MarketDetailFragmentPresenter extends BasePresenter<MarketDetailFragment> {
    /**
     * 获取币种信息
     * <p>
     * RxBus {@link com.sskj.gcc.ui.fragment.HangqingFragment#refreshCoin(CoinBean)}
     *
     * @param code 币种名称
     */
    public void getProduct(String code) {
        OkGo.<HttpData<List<CoinBean>>>get(HttpConfig.BASE_URL + HttpConfig.GET_PRO)
                .params("code", code)
                .execute(new JsonCallBack<HttpData<List<CoinBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<CoinBean>>> response) {
                        HttpData<List<CoinBean>> httpData = response.body();
                        if (httpData.getCode() == HttpConfig.OK) {
                            mView.setData(httpData.getData());
                        }
                    }
                });
    }
}
